<!--
 * @Author: asushiye
 * @Date: 2020-07-02 15:30:23
 * @Commit: file content
-->
<page-header autoTitle="false" />

<nz-card>
  <form nz-form nzLayout="inline" se-container>
    <se label="文件名" labelWidth="0">
      <input nz-input name="name" placeholder="请输入文件名, 支持模糊查询" [(ngModel)]="queryParams.fileName" />
    </se>
    <se>
      <button nz-button nzType="primary" (click)="query()" [nzLoading]="isLoading">查询</button>
      <button nz-button nzType="default" (click)="upload()">
        <span>上传文件</span>
        <i nz-icon nzType="file-excel"></i>
      </button>
      <button nz-button [nzType]="'default'" (click)="downloadTemplate()">
        <span>下载模板</span>
        <i nz-icon nzType="download"></i>
      </button>
    </se>
  </form>
  <st #st [data]="rows" [columns]="columns" [expand]="expand" size="small" expandRowByClick expandAccordion>
    <ng-template #expand let-item let-index="index" let-column="column">
      <p>执行状态： {{ item!.syncMsg }}</p>
      <p>文件： {{ item!.file }}</p>
      <p>创建人： {{ item!.createdBy }}； 创建时间： {{ item!.createdDate }}</p>
      扩展内容： {{ item!.extendedFields }}
    </ng-template>
  </st>
</nz-card>

<nz-drawer
  [nzSize]="drawer_size"
  [nzVisible]="drawer_visible"
  nzPlacement="right"
  [nzTitle]="drawer_Title"
  [nzExtra]="extra"
  (nzOnClose)="drawer_close()"
>
  <ng-container *nzDrawerContent>
    数据库：
    <nz-select
      id="currentDbType"
      style="width: 140px"
      [(ngModel)]="currentDbType"
      (ngModelChange)="dbTypeChange($event)"
      [ngModelOptions]="{ standalone: true }"
    >
      <nz-option *ngFor="let item of databaseTypes" [nzLabel]="item" [nzValue]="item" />
    </nz-select>
    <button nz-button nzType="default" (click)="generateScript()" [nzLoading]="isLoading">生成脚本</button>
    数据源：
    <nz-select id="currentDbSource" style="width: 180px" [(ngModel)]="currentDbSource" [ngModelOptions]="{ standalone: true }">
      <nz-option *ngFor="let item of databaseSources[currentDbType]" [nzLabel]="item" [nzValue]="item" />
    </nz-select>
    <button nz-button nzType="primary" (click)="executeScript()" [nzLoading]="isLoading">执行脚本</button>
    <!-- <button nz-button nzType="default"  (click)="viewLog2()" [nzLoading]="isLoading"> <i nz-icon nzType="right"></i> 查看日志</button> -->
    <ngx-codemirror
      [(ngModel)]="scriptAll"
      [options]="{
        lineNumbers: true,
        theme: 'idea',
        mode: 'sql',
        height: '500',
        readOnly: true
      }"
    />
  </ng-container>
</nz-drawer>
<ng-template #extra>
  <button nz-button nzType="default" (click)="drawer_close()">关闭</button>
  &nbsp;
  <button nz-button nzType="default" (click)="viewLog2()" [nzLoading]="isLoading"> <i nz-icon nzType="right"></i> 查看日志</button>

  <!-- <button nz-button nzType="primary" (click)="drawer_close()">OK</button> -->
</ng-template>
